﻿<HTML>

<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />  
  <TITLE>HeO Code Guidelines</TITLE>
  <LINK HREF="doc.css" REL=STYLESHEET>
</HEAD>


<BODY>

  <H1>HeO Code Guidelines</H1>

  <A HREF="projects.html">[Previous]</A><A HREF="authors.html">[Next]</A><A HREF="../index.html">[Home]</A>

  <H2>&nbsp;</H2>

  <P>
    In order to avoid mistakes and to keep consistency implementing problem-specific classes use the following style guide.
  </P>

  <TABLE WIDTH="800px">
    <TBODY>

      <TR>
        <TH COLSPAN="2">Naming</TH>
      </TR>

      <TR>
        <TD WIDTH="25%">Variable Names</TD>
        <TD WIDTH="75%">Variable names are all lower-case, with underscores between words. Class member variables have trailing underscores.<BR>e.g., <TT>my_local_variable</TT>, <TT>my_member_variable_</TT></TD>
      </TR>

      <TR>
        <TD>Constant Names</TD>
        <TD>Constants start with k followed by mixed case.<BR>e.g., <TT>kMyConstant</TT></TD>
      </TR>

      <TR>
        <TD>Function Names</TD>
        <TD>Regular functions have mixed case with no underscores between words. Member functions start with lower-case and then followed by mixed case with underscores between words.<BR>e.g., <TT>MyFunction()</TT>, <TT>my_Member_Function()</TT></TD>
      </TR>

      <TR>
        <TD>Namespace Names</TD>
        <TD>Namespace names are all lower-case.<BR>e.g., <TT>heo::</TT>, <TT>mpi::</TT>, <TT>meta::</TT></TD>
      </TR>

      <TR>
        <TD>Enumerator Names</TD>
        <TD>Enumerators are all upper-case, with underscores between words.<BR>e.g., <TT>NATIVE_MPI_TYPE</TT></TD>
      </TR>

<!--
      <TR>
        <TD>Template Arguments</TD>
        <TD>Template arguments are single upper-case letters.<BR>e.g., <TT>template&lt;class P, class S, class C&gt;</TT></TD>
      </TR>
-->

      <TR>
        <TD>Algorithm-specific Class Names</TD>
        <TD>Algorithm-specific class and template names start with the abbreviation of the optimization method.<BR>e.g., <TT>GA</TT>, <TT>GA_MPI</TT>, <TT>GA_OMP</TT>, <TT>GA_Config</TT></TD>
      </TR>

      <TR>
        <TD>Problem-specific Class Names</TD>
        <TD>Problem-specific class names start with the abbreviation of the problem and end with the abbreviation of the optimization method (if needed).<BR>e.g., <TT>MaxSat_Problem</TT>, <TT>MaxSat_Solution</TT>, <TT>MaxSat_Solution_GA</TT></TD>
      </TR>



      <TR>
        <TH COLSPAN="2">Classes</TH>
      </TR>

      <TR>
        <TD>Doing Work in Constructors</TD>
        <TD>Do only trivial initialization in a constructor. If at all possible, use an <TT>init()</TT> method for non-trivial initialization.</TD>
      </TR>

      <TR>
        <TD>Explicit Constructors</TD>
        <TD>Use the C++ keyword <TT>explicit</TT> for constructors with one argument.</TD>
      </TR>

      <TR>
        <TD>Copy Constructors</TD>
        <TD>Use copy constructors only when your code needs to copy a class; most do not need to be copied and so should use <TT>DISALLOW_COPY_AND_ASSIGN</TT>.</TD>
      </TR>

      <TR>
        <TD>Structs vs. Classes</TD>
        <TD>Use a struct only for passive objects that carry data; everything else is a class.</TD>
      </TR>

 

      <TR>
        <TH COLSPAN="2">Other C++ Features</TH>
      </TR>

      <TR>
        <TD>Variable-Length Arrays and <TT>alloca()</TT></TD>
        <TD>We do not allow variable-length arrays or <TT>alloca()</TT>.</TD>
      </TR>

      <TR>
        <TD>Exceptions</TD>
        <TD>We do not use C++ exceptions.</TD>
      </TR>

      <TR>
        <TD>Preincrement and Predecrement</TD>
        <TD>Use prefix form (<TT>++i</TT>) of the increment and decrement operators with iterators and other template objects.</TD>
      </TR>

      <TR>
        <TD>Use of <TT>const</TT></TD>
        <TD>We strongly recommend that you use <TT>const</TT> whenever it makes sense to do so.</TD>
      </TR>




      <TR>
        <TH COLSPAN="2">Formatting</TH>
      </TR>

      <TR>
        <TD>Spaces vs. Tabs</TD>
        <TD>Use only spaces, and indent 4 spaces at a time.</TD>
      </TR>


      <TR>
        <TD>Namespace Formatting</TD>
        <TD>The contents of namespaces are not indented.</TD>
      </TR>


      <TR>
        <TD>Loops and Conditionals</TD>
        <TD>Format loops and conditionals as follows:
            <DIV CLASS="code">
              for/while (...)<BR>
              {<BR> 
              &nbsp;&nbsp;&nbsp;&nbsp;op;<BR>
              }<BR>
              if (...)<BR> 
              {<BR>
              &nbsp;&nbsp;&nbsp;&nbsp;op1;<BR>
              }<BR>
              else<BR>
              {<BR>
              &nbsp;&nbsp;&nbsp;&nbsp;op2;<BR>
              }
            </DIV</TD>
      </TR>


    </TBODY>
  </TABLE>

  <P>
  </P>

  <H2>&nbsp;</H2>

  <A HREF="projects.html">[Previous]</A><A HREF="authors.html">[Next]</A><A HREF="../index.html">[Home]</A>

</BODY>

</HTML>


